-
Notifications
You must be signed in to change notification settings - Fork 71
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Allow inheriting LayerFilter to customize filter behavior. #390
base: main
Are you sure you want to change the base?
Conversation
…partyhuang_layerFilter # Conflicts: # test/baseline/version.json resolved by e5ca671 version
src/layers/Layer.cpp
Outdated
std::shared_ptr<Image> Layer::createPictureImage(std::shared_ptr<Picture> picture, Point* offset) { | ||
if (picture == nullptr) { | ||
return nullptr; | ||
} | ||
auto bounds = picture->getBounds(); | ||
bounds.roundOut(); | ||
auto matrix = Matrix::MakeTrans(-bounds.x(), -bounds.y()); | ||
auto image = Image::MakeFrom(std::move(picture), static_cast<int>(bounds.width()), | ||
static_cast<int>(bounds.height()), &matrix); | ||
if (offset) { | ||
*offset = Point::Make(bounds.x(), bounds.y()); | ||
} | ||
return image; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这个加个静态函数是不是就行了?没有访问任何layer的属性。
src/layers/Layer.cpp
Outdated
return image; | ||
} | ||
|
||
std::shared_ptr<Picture> Layer::getLayerContents(const DrawArgs& args, float contentScale) { | ||
if (FloatNearlyZero(contentScale)) { | ||
return nullptr; | ||
} | ||
Recorder recorder; | ||
Recorder recorder{}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
是 Recorder recorder = {}; 编译器会优化成只有一次构造函数调用的。
} | ||
return lastFilter; | ||
Paint paint; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Paint paint = {};
No description provided.